package top.wangkylin.pdf;


import top.wangkylin.domain.PdfParam;
import top.wangkylin.util.PdfUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author wangqi
 * @date 2025/7/28.
 */
public class Main {
    public static void main(String[] args) {
        String realPath = Objects.requireNonNull(Main.class.getClassLoader().getResource("")).getPath();
        List<PdfParam> params = new ArrayList<>();
        // 第一页+第二页
        params.add(new PdfParam("name", "李四"));
        params.add(new PdfParam("sex", "男"));
        params.add(new PdfParam("age", "25"));
        params.add(new PdfParam("caseNo", "NO1111111111111"));
        params.add(new PdfParam("principalDoctor", "王五"));
        params.add(new PdfParam("cureOrg", "华中科技大学"));
        params.add(new PdfParam("treatmentDate", "2025-07-11"));
        params.add(new PdfParam("patientMainSuit", "患者主诉"));
        params.add(new PdfParam("doctorSuit", "医生建议"));
        params.add(new PdfParam("photo", realPath + "/photo.jpg", true));

        // 第三页
        // 面像分析
        params.add(new PdfParam("facePhoto1", realPath + "/photo.jpg", true));
        params.add(new PdfParam("facePhoto2", realPath + "/photo.jpg", true));
        params.add(new PdfParam("facePhoto3", realPath + "/photo.jpg", true));
        // 正面型
        params.add(new PdfParam("frontFace1", "基本均等面型"));
        params.add(new PdfParam("frontFace2", "基本居中"));
        // 微笑
        params.add(new PdfParam("smile", "正常"));
        // 软组织(多选)
        params.add(new PdfParam("softTissue", "无明显异常"));
        // 颏位
        params.add(new PdfParam("submentalPosition", "正常"));
        // 鼻唇角
        params.add(new PdfParam("nasolabialAngle", "正常"));
        // 颏唇沟
        params.add(new PdfParam("mentolabialSulcus", "正常"));

        // 第四页
        params.add(new PdfParam("mouthPhoto1", realPath + "/photo.jpg", true));
        params.add(new PdfParam("mouthPhoto2", realPath + "/photo.jpg", true));
        params.add(new PdfParam("mouthPhoto3", realPath + "/photo.jpg", true));
        params.add(new PdfParam("mouthPhoto4", realPath + "/photo.jpg", true));
        params.add(new PdfParam("mouthPhoto5", realPath + "/photo.jpg", true));
        params.add(new PdfParam("mouthPhoto6", realPath + "/photo.jpg", true));
        params.add(new PdfParam("oralHygiene", "差、牙龈红肿"));
        params.add(new PdfParam("toothDecay", "有龋坏"));
        params.add(new PdfParam("labialFrenulum", "唇系带短？"));
        params.add(new PdfParam("toothException", "无特殊"));
        params.add(new PdfParam("gingivalRecession", "无特殊"));

        // 第五页
        handleHellman(params, realPath);


        params.add(new PdfParam("maxillaCanines", "mm"));
        params.add(new PdfParam("maxillaFirst", "mm"));
        params.add(new PdfParam("maxillaSecond", "mm"));
        params.add(new PdfParam("maxillaFirstWidth", "mm"));
        params.add(new PdfParam("maxillaBowType", "卵圆"));
        params.add(new PdfParam("maxillaSymmetry", "基本对称"));
        params.add(new PdfParam("maxillaCrowding", "轻"));
        params.add(new PdfParam("jawCanines", "mm"));
        params.add(new PdfParam("jawFirst", "mm"));
        params.add(new PdfParam("jawSecond", "mm"));
        params.add(new PdfParam("jawFirstWidth", "mm"));
        params.add(new PdfParam("jawBowType", "卵圆"));
        params.add(new PdfParam("jawSymmetry", "基本对称"));
        params.add(new PdfParam("jawCrowding", "轻"));

        // 第六页
        params.add(new PdfParam("molarLeft", "Ⅲ"));
        params.add(new PdfParam("molarRight", "Ⅲ"));
        params.add(new PdfParam("fangsLeft", "Ⅲ"));
        params.add(new PdfParam("fangsRight", "Ⅲ"));
        params.add(new PdfParam("anteriorToothOverbite", "过大 3.3 mm"));
        params.add(new PdfParam("posteriorToothCoverage", "正常"));
        params.add(new PdfParam("individualIncisorOverbite", "无"));
        params.add(new PdfParam("anteriorOverbite", "正常"));
        params.add(new PdfParam("posteriorOverbite", "正常"));
        params.add(new PdfParam("speeCurve", "平"));
        params.add(new PdfParam("midline", "上下颌中线一致"));

        // 第七页
        params.add(new PdfParam("panoramicFilmImg", realPath + "/photo.jpg", true));
        params.add(new PdfParam("stagesOfToothDevelopment", "替牙列期"));
        params.add(new PdfParam("teethNumber", "无明显异常"));
        params.add(new PdfParam("impactedTeeth", "46阻生"));
        params.add(new PdfParam("rootTip", "无明显异常"));
        params.add(new PdfParam("jawCondition", "无明显异常"));
        params.add(new PdfParam("jointConditions", "关节不对称？"));
        params.add(new PdfParam("nasalConditions", "待查"));

        // 第八页
        params.add(new PdfParam("lateralCephalogramImg", realPath + "/photo.jpg", true));
        params.add(new PdfParam("cervicalSpineReferValue", ""));
        params.add(new PdfParam("airway_analyze", ""));
        params.add(new PdfParam("snaValue", ""));
        params.add(new PdfParam("snbValue", ""));
        params.add(new PdfParam("anbValue", ""));
        params.add(new PdfParam("fmaValue", ""));
        params.add(new PdfParam("snmpValue", ""));
        params.add(new PdfParam("snValue", ""));
        params.add(new PdfParam("u1snValue", ""));
        params.add(new PdfParam("impaValue", ""));
        params.add(new PdfParam("cervicalSpineValue", ""));
        params.add(new PdfParam("snaLabor", ""));
        params.add(new PdfParam("snbLabor", ""));
        params.add(new PdfParam("anbLabor", ""));
        params.add(new PdfParam("fmaLabor", ""));
        params.add(new PdfParam("snmpLabor", ""));
        params.add(new PdfParam("snLabor", ""));
        params.add(new PdfParam("u1snLabor", ""));
        params.add(new PdfParam("impaLabor", ""));
        params.add(new PdfParam("cervicalSpineLabor", ""));

        // 第九页
        params.add(new PdfParam("CTAirwayImagingImg", realPath + "/photo.jpg", true));
        params.add(new PdfParam("analysisConclusion", "提示气道容积尚可，OSA发生率低"));

        // 第十页
        params.add(new PdfParam("horizontal", ""));
        params.add(new PdfParam("sagittal", "凹面型,骨性II类,磨牙-左:III,磨牙-右:III"));
        params.add(new PdfParam("vertical", "短面型,均角"));
        params.add(new PdfParam("dentition", "唇倾,牙列拥挤"));
        params.add(new PdfParam("tooth", "无明显异常"));
        params.add(new PdfParam("periodontal", "无明显异常"));
        params.add(new PdfParam("joint", "无明显异常"));
        params.add(new PdfParam("airway", "尚可"));
        params.add(new PdfParam("softTissue_diagnosis", "无明显异常"));
        params.add(new PdfParam("laceUp", "无明显异常"));
        params.add(new PdfParam("badOralHabits", ""));
        
        

        PdfUtil.makePdf(params, "病例报告.pdf", "case-report.pdf");
    }

    /**
     * 处理地狱图
     * @param params
     * @param realPath
     */
    private static void handleHellman(List<PdfParam> params, String realPath) {
        String[][] hellmanData = new String[][] {
            {"0", "0", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "0"},
            {"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},
            {"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},
            {"0", "0", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "0"}
        };
        String[][] hellmanFileName = new String[][] {
            {"8", "7", "6", "5", "4", "3", "2", "1", "1", "2", "3", "4", "5", "6", "7", "8"},
            {"5", "4", "3", "2", "1", "1", "2", "3", "4", "5"},
            {"5", "4", "3", "2", "1", "1", "2", "3", "4", "5"},
            {"8", "7", "6", "5", "4", "3", "2", "1", "1", "2", "3", "4", "5", "6", "7", "8"}
        };

        for (int i = 0; i < hellmanData.length; i++) {
            for (int j = 0; j < hellmanData[i].length; j++) {
                if (i == 0 || i == 3) {
                    params.add(new PdfParam(String.valueOf(i+1) + String.valueOf(j+1), realPath + "/" + ("1".equals(hellmanData[i][j]) ? "b" : "w") + hellmanFileName[i][j] + ".png", true));
                } else {
                    params.add(new PdfParam(String.valueOf(i+1) + String.valueOf(j+1), realPath + "/" + ("1".equals(hellmanData[i][j]) ? "bl" : "wl") + hellmanFileName[i][j] + ".png", true));
                }
            }
        }

    }
}
